Web application code conversion system

ABSTRACT

A web application code conversion system ( 100 ) translates web application code written in a first language into a second language. A scanner ( 104 ) scans the old code and generates tokens corresponding to keywords, variable names, and other strings in the old code. A parser ( 106 ) determines the functional equivalents of the tokens in the new code and generates the new code in the second language.

REFERENCE TO COMPUTER PROGRAM LISTING APPENDIX

[0001] One CD-ROM containing a file entitled “AppendixA.txt” illustrating one example of language conversion code is filed herewith and incorporated by reference.

TECHNICAL FIELD

[0002] The present invention is directed to code used to generate web applications, and more particularly to a system that converts web application code from one language to another.

BACKGROUND OF THE INVENTION

[0003] Developing web applications often require a great deal of time and investment. As technology changes, however, web applications that are several years old may be written in a language that is being phased out by a new language. New functions may be added to an existing web application through patches written in the old language to preserve the initial investment of developing the web application, but this method fails to take advantage of new technology developments. Adopting the new technology incorporates new technology developments into the web application, but this method may fail to preserve previous investments in the application.

[0004] There is a desire for a system that can take advantage of new web application technology while preserving investments made into an existing web application using older technology.

SUMMARY OF THE INVENTION

[0005] Accordingly, the invention is directed to a web application code conversion system that can automatically convert web application code from a first language to a second language. The system includes a scanner that reads old code written in the first language and detects tokens that each correspond with a language element in the old code. A parser then receives each token from the scanner and uses a state transition table to determine the actions necessary to generate new code in the second language.

[0006] By translating web application code from an old language into a new language, the inventive system preserves investments made in old technologies while still taking advantage of new technological developments.

BRIEF DESCRIPTION OF THE DRAWINGS

[0007]FIG. 1 is a block diagram illustrating an overall system according to one embodiment of the invention; and

[0008]FIG. 2 is a block diagram illustrating processes carried out by a portion of the system shown in FIG. 1.

DETAILED DESCRIPTION OF THE EMBODIMENTS

[0009] Generally, the invention is directed to a system that can convert a web application program written in a first language into a second language, preserving all the functionalities of the original web application. For example, if a web application is originally written in PL/SQL, the inventive system can convert the PL/SQL code to a different language, such as VB.net. The input code and the generated output code will be functionally identical because the output code is simply generated from the input code and written in a different language.

[0010] One embodiment of the inventive system 100 is an object-oriented structure, as illustrated in FIG. 1. A main module/interface 102 acts as the interface between a user and the system 100. The system also includes a scanner 104, a parser 106, one or more language table modules 108, and one or more source class modules 110. As will be explained in greater detail below, the scanner 104 and parser 106 conduct the actual code translation functions, but the language table module 108 and the source class module 100 provide greater flexibility by accommodating multiple languages and/or source file formats. The scanner 104 scans the input code and breaks the scanned input into words and symbols according to the rules of the old language, while the parser 106 incorporates the code generator that translates the input code into a functionally equivalent output code in the new language.

[0011] In the example shown in FIG. 1, the user can select via the main module 102 among two possible input languages (e.g., PL/SQL 112 and Progress 114) and two possible output languages (e.g., VB.net 116 and C# 118). Of course, any number of input and output languages can be incorporated into the system 100; because each language has its own separate object class, the system 100 itself does not need to be reprogrammed to accommodate a new input and/or output language. The scanner 104 and parser 106 follow the same rules regardless of the input and output code language, but they only use the languages selected by the user to carry out the conversion.

[0012] This flexibility is implemented through object inheritance. Language tables 108 is a base class that defines the structure of the input language scanner 104 and parse tables used by the parser 106. The scanner 104 and basic parser 106 functionality are implemented to work with any instance of the language tables class 108. The PL/SQL 112 class inherits from the language tables 108, following the same structure as the language tables class 108 but also including specific table information for the PL/SQL 112 input language. When the user selects PL/SQL as the input language, an object of that type (i.e., the class that defines the tables for the selected language) is instantiated for use by the scanner 104 and parser 106. Likewise on the output, the parser 106 class is a base class that includes parsing functions, but only selected output language-independent code generation functions. Language specific classes such as VB.net 116 are implemented to inherit from the parser 106 and supply language-specific code generation rules. Any number of classes could be implemented with code generation for different languages; when the user selects the desired output language, the main module 102 instantiates the object of that specific type.

[0013] The source class module 110 allows the user to select the source of the input code (e.g., a file 120 or a database 122). Like the other system components, the scanner 104 module itself does not need to know the nature of the input source in order to read in the input code; it only needs a source object that inherits from the source 110 class as the file 120 and database 122 classes do. The system's structure therefore allows the addition of different input and output languages as well as source formats without modifying the system 100 itself.

[0014] Although FIG. 1 shows an object-oriented approach to the inventive system, the language table 108, source class module 110, and parser 106 may themselves incorporate rules corresponding to specific languages and/or source formats, particularly if the system 100 will be used only to convert web application code from one known language and one known format into another known language. This variation still would fall within the scope of the invention.

[0015]FIG. 2 illustrates the operation of the scanner 104 and the parser 106 in more detail. After the user selects the input code language, the scanner 104 reads each individual character of the input code (block 200) and groups the individual characters into words and symbols (block 202) to generate “tokens”. The scanner 104 also identifies keywords in the old code and separates the keywords from unknown strings, such as variable names (block 204). The scanner 104 recognizes the keywords based on the language-specific information from the language table 108. Because each language may have its own specialized keywords, the language table 108 provides the scanner 104 with a virtual vocabulary so that it can group the characters into tokens usable by the chosen input code language. The tokens themselves may be formed via any known state transition system.

[0016] Once the scanner generates the tokens corresponding to the old code, the tokens are sent to the parser 106 for actual translation into the new language. When the parser 106 receives a token from the scanner 104 (block 206), the parser 106 determines the token type (e.g., symbols, keywords, numbers, variable names, etc.) and a current operational state of the parser 106 (block 208). The token type and state information are used to enter a parse table to find new states and actions that will eventually generate the output code (block 210). The parse table referenced by the parser 106 dictates how the translation actually takes place; as noted above, the parser 106 runs the selected output language module 116, 118 and translates the tokens according to the rules in the selected module 116, 118 to generate the new code (block 212).

[0017] The parse table is built like a code compiler that has a scanner that reads the input code one character at a time and builds the characters into words or separates symbols from the other characters. The parse table used by the parser 106 can be any state transition table adapted to generate code. State transition tables are known in the art for compiling data and generating object code. Thus, developing a state transition table that can generate high-level language code instead of object code is within the capabilities of one of ordinary skill in the art. Generally, the actions called for in the parse table are designed to generate new code that functionally corresponds with the old code.

[0018] As the parser 106 receives each new token, it decides what action it should take from the parse table. From the parse table information, the parser 106 can determine the function of each statement in the old code and generate new code that carries out an equivalent function (block 212). In some cases, there is not a one-to-one correspondence between old code commands and new code commands; these differences can be incorporated into the rules and actions called by the parse table. Depending on the differences between the old code and the new code, some tokens can be translated literally, while other tokens need to be renamed to conform to the requirements of the new code. Further, some token sequences require restructuring to carry out the same function in the new language. Because the parser 106 receives the tokens sequentially, the program flow of the old code can be preserved when it is translated into the new code.

[0019] Once the parser generates the new code, the new code can be output of the main module/interface 102 for display, storage or further processing. For example, the new code can be edited, manipulated, and otherwise treated as if the web application had been originally written in the new language rather than translated from an old language.

[0020] One post-processing option is shown in FIG. 2. As is known in the art, many web applications have static content (such as HTML) and dynamic content generated by programming code mixed together. Although newer languages include form editors that simplify maintenance of the static content, the new code generated by the parser 106 may still have the limited functionalities of the old language and fail to distinguish static content from dynamic content.

[0021] To take advantage of form editing functions in the new language, the system 100 may allow a user to identify and separate the static output statements (e.g. a simple print statement of a literal string) from the dynamic code (block 214), forward the static web page content to a form editor and forward the dynamic code to a code editor (block 216). In one embodiment, the system identifies the static strings in the new code and concatenates a series of static strings together as a single static string. Once the system 100 identifies the static code, it can separate the static code from the dynamic code. The system 100 may also detect statements that could generate dynamic content, including print statements or subroutine calls, and rewrite the new code so that any dynamic content is placed into program variables rather than being output directly. The system 100 also inserts references to the program variables corresponding to the dynamic content into the static content so that, when the web application program is executed, the output from the dynamic code is inserted at the proper locations in the static content. As a result, separating the static code from the dynamic code allows a user to edit the static content with a visual form editor rather than editing the code that writes out content statements.

[0022] Thus, the inventive conversion tool can convert old web application code into new web application code, eliminating the need to rewrite the web application code from scratch to accommodate new languages. Further, the conversion tool may be designed to separate static content from dynamic content, allowing static portions of the new code to be edited using a form editor.

[0023] It should be understood that various alternatives to the embodiments of the invention described herein may be employed in practicing the invention. It is intended that the following claims define the scope of the invention and that the method and apparatus within the scope of these claims and their equivalents be covered thereby. 

What is claimed is:
 1. A system that converts an input code in a first language into an output code in a second language, comprising: a scanner that reads the input code and generates tokens corresponding to the input code; and a parser that receives the tokens and generates the output code from the tokens.
 2. The system of claim 1, wherein the scanner reads individual characters in the input and generates the tokens by grouping the individual characters together to form the tokens.
 3. The system of claim 1, wherein each token has a token type and the parser uses a parse table, and wherein the parser generates the output code by referencing the parse table based on the token type and a current state.
 4. The system of claim 3, wherein the token type is at least one selected from the group consisting of a keyword, a symbol, a number, and a variable name.
 5. The system of claim 1, further comprising at least one output language module coupled to the parser, wherein the parser generates the output code based on information in the output language module.
 6. The system of claim 1, further comprising a language table coupled to the scanner, wherein the scanner generates the tokens based on information in the language table.
 7. The system of claim 6, further comprising at least one input language module inherited from the language table, wherein the input language module contains language-specific information to be accessed by the language table for use by the scanner.
 8. The system of claim 1, further comprising a source class module coupled to the scanner, wherein the scanner accesses the source class module for to read the input code.
 9. The system of claim 1 further comprising: a language table coupled to the scanner, wherein the scanner generates the tokens based on information in the language table; at least one input language module inherited from the language table, wherein the input language module contains language-specific information to for use by at least one of the scanner and parser; at least one output language module inherited from the parser, including the rules to generate code in the output language; a source class module coupled to the scanner, wherein the scanner accesses the source class module to read the input code; and an interface coupled to at least one of the language table, the parser, and the source class module to allow selection of an input language, an output language, and a source class, respectively.
 10. A method of converting an input code in a first language into an output code in a second language, comprising: reading characters in the input code; generating tokens from the characters; referencing a parse table based on each token and a current state; and generating a portion of the output code from each token based on the parse table. 